<?php
final class Zeus_Core_Model_App
{

	/**
	 * Configuration Object
	 *
	 * @var Zeus_Core_Model_Config
	 */
	private $_config;

	/**
	 * Returns the config object and initializes it if it should not exist.
	 *
	 * @return Zeus_Core_Model_Config
	 */
	public function getConfig()
	{
		// Check whether the config is already initialized
		if($this->_config == null)
		{
			// Initialize config object
			// The config object loads the configuration
			$this->_config = new Zeus_Core_Model_Config();
		}

		// Return the config object
		return $this->_config;
	}

	/**
	 * Run the Zeus application.<br><br>
	 *
	 * That everything get initiated, the controllers looked up
	 * and executed and everything gets to work.
	 *
	 * @param int $type
	 */
	public function run($type)
	{
		// Load the configuration
		$this->getConfig()->load();

		// Switch the run type
		switch($type)
		{
			// The type is normal running
			case Zeus::ZEUS_RUN:

				// Look up the best controller
				$this->lookupController();

				// End the switch case
				break;

			// The type is install mode
			case Zeus::ZEUS_INSTALL:

				// Load the installation options
				$this->getConfig()->loadModuleInstallationFiles();

				// Lookup for the best install controller
				$this->lookupInstallController();

				// End the switch case
				break;
		}
	}

	// TODO
	private function lookupController()
	{
		// TODO: search module with the highest frontend default controller level
		// TODO: or run frontend controller for url
	}

	// TODO
	private function lookupInstallController()
	{
		// TODO
	}

}